package cn.icare.cms.controller.restful;

import cn.icare.cms.MoneyInService;
import cn.icare.cms.aop.UserLog;
import cn.icare.cms.model.vo.rest.RespMsgVO;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@CrossOrigin
@RestController
@RequestMapping(value = "/rest/moneyin")
@Api(tags = "REST收入明细列表")
public class MoneyInController extends BaseController {
    @Resource
    private MoneyInService moneyInService;
    private final String FALL_STRING = "请求失败,服务繁忙!";



    /**
     * URL:http://{ip}:{port}/rest/moneyIn?args={args}
     * method:GET
     *
     * @return
     */
    @GetMapping()
    @HystrixCommand(fallbackMethod = "getListFall")
    @ApiOperation(value = "获取收入明细列表", notes = "获取收入明细列表")
    public ResponseEntity<RespMsgVO> getList(
            @RequestParam(name = "code", required = false) String  code
            ,@RequestParam(name = "orderCode", required = false) String  orderCode
            ,@RequestParam(name = "memberName", required = false) String  memberName
            ,@RequestParam(name = "beginTime", required = false) String  beginTime
            ,@RequestParam(name = "endTime", required = false) String  endTime
            ,@RequestParam(name = "payType", required = false) Integer  payType
            ,@RequestParam(name = "pageNum", required = false) Integer  pageNum
            ,@RequestParam(name = "pageSize", required = false) Integer  pageSize
            ,@RequestParam(name = "sortType", required = false) Integer  sortType
    ) {
        return super.getRespOk(this.moneyInService.getList(code,orderCode,memberName
        ,payType,beginTime,endTime,pageNum,pageSize,sortType));
    }




    //region fallback methods


    private ResponseEntity<RespMsgVO> getListFall(
            String code, String orderCode,String memberName,
            String beginTime,String endTime,Integer payType,
            Integer pageNum, Integer pageSize,Integer sortType
    ) {
        return super.getRespFail(this.FALL_STRING);
    }

    //endregion
}
